<template>
	<view>
		<view class="search">
			<icon type="search" color="white" size="10"></icon>
			<input type="text" value="" placeholder="搜索商品" placeholder-class="placeholder"/>
		</view>
		<view class="list" v-if="orders.length > 0">
			<!-- row 循环体 -->
			<view class="row" v-for="(item,index) of orders" :key="item.id">
				<view class="products">
					<view class="imagebox" v-for="(item2,index) of item.child" :key="index">
						<image :src="item2.img" mode="widthFix"></image>
						<text class="title">{{item2.goodsname}}</text>
					</view>
				</view>
				<view class="info">
					<text  space="nbsp">总计{{item.countnumber}}商品  </text>  
					<text>应付金额 ￥:{{item.countmoney}}</text>
				</view>
			</view>
		</view>
		<view class="tishi" v-else>
			没有数据亲！
		</view>
	</view>
</template>

<script>

/*

查看全部订单  已支付 1   未支付2	   待发货 3  已完成的4

/getorder
{
	uid
}
已支付
{
	uid
	status:1
}


/api/orders
*/ 

import Http from '@/utils/http.js'
import {apiurl} from '@/utils/config.js'

let { token,uid } = getApp().userInfo

	export default {
		data() {
			return {
				orders:[]
			}
		},
		mounted(){
			this._getOrders()
		},
	
		methods: {
			async _getOrders(){
				//console.log( token,uid )
				
				let result = await Http({
					url:'/api/orders',
					data:{
						uid
					},
					header:{
						authorization:token
					}
				})
				console.log( result,'订单' )
				result.data.list.forEach(item1=>{
					item1.child.forEach(item2=>{
						item2.img = apiurl + item2.img
					})
				})
				this.orders = result.data.list
			}
		},
		
	}
</script>

<style>
.search{
		margin: 50rpx;
		height: 80rpx;
		background-color: #f26b11;
		border-radius: 80rpx;
		color: white;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	icon{
		margin:0 10rpx 0 250rpx;
	}
	.placeholder{
		color: white;
		font-size: 25rpx;
	}
	.row{
		margin: 10rpx 20rpx;
		/* height: 240rpx; */
		border: 1rpx solid #AAAAAA;
		border-radius: 30rpx;
	}
	
	.imagebox{
		/* float: left; */
		margin:10rpx;
		display: flex;
	}
	.imagebox .title{
		margin-top: 30rpx;
	}
	.products{
		overflow: hidden;
	}
	image{
		width: 160rpx;
		margin-left: 10rpx;
	}
	.info{
		display: flex;
		justify-content: space-between;
		font-size: 25rpx;
		/* width: 340rpx; */
		padding: 20rpx;
		text-align: right;
	}
	.info text:nth-of-type(2){
		color: red;
	}
	.info text:nth-of-type(3){
		font-size: 20rpx;
		color: #AAAAAA;
	}
	.tishi{
		line-height: 200rpx;
		text-align: center;
		font-size: 40rpx;
		color: #006699;
	}
</style>
